/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package NM_Procesos;

import NM_ClasesGenerales.*;
import java.util.ArrayList;
import java.util.List;
import metodossabre.Pnr;

/**
 *
 * @author USER
 */
public class RecuperarPNR {

    public Solicitud Sabre(String oPNR) throws Exception {

        Solicitud objSolicitud = null;        
        List<Passenger> list_pas = new ArrayList<Passenger>();        
        List<Itinerario> list_iti = new ArrayList<Itinerario>();


        metodossabre.SabreService service = new metodossabre.SabreService();
        Pnr xPnr = null;

        try {

            metodossabre.Sabre port = service.getSabrePort();
            xPnr = new Pnr();
            xPnr = port.recuperarPNR(oPNR);
                
            if (xPnr != null) {
                
                objSolicitud = new Solicitud();

                objSolicitud.setPNR(xPnr.getCodigo());
                
                for(int i=0;i<xPnr.getObjPasseger().size();i++){
                    Passenger passengeraux =  new Passenger();
                    passengeraux.setNumPassenger(xPnr.getObjPasseger().get(i).getNumPassenger());
                    passengeraux.setStrDateBirthday(xPnr.getObjPasseger().get(i).getStrDateBirthday());
                    passengeraux.setStrGenero(xPnr.getObjPasseger().get(i).getStrGenero());
                    passengeraux.setStrPassenegerType(xPnr.getObjPasseger().get(i).getStrPassenegerType());
                    passengeraux.setStrPassengerName(xPnr.getObjPasseger().get(i).getStrPassengerName());
                    passengeraux.setStrPassengerSurname(xPnr.getObjPasseger().get(i).getStrPassengerSurname());
                    passengeraux.setStrReferenceNumber(xPnr.getObjPasseger().get(i).getStrReferenceNumber());
                    passengeraux.setStrReferenceType(xPnr.getObjPasseger().get(i).getStrReferenceType());
                    list_pas.add(passengeraux);
                }
                

                for(int i=0;i<xPnr.getObjItinerario().size();i++){
                    
                    Itinerario ite = new Itinerario();
                    ite.setNumFly(xPnr.getObjItinerario().get(i).getNumFly());
                    ite.setNumItinerario(xPnr.getObjItinerario().get(i).getNumItinerario());
                    ite.setStrAir(xPnr.getObjItinerario().get(i).getStrAir());
                    ite.setStrCityArrival(xPnr.getObjItinerario().get(i).getStrCityArrival());
                    ite.setStrDateTimeArryval(xPnr.getObjItinerario().get(i).getStrDateTimeArryval());
                    ite.setStrCityDeparture(xPnr.getObjItinerario().get(i).getStrCityDeparture());
                    ite.setStrDateTimeDeparture(xPnr.getObjItinerario().get(i).getStrDateTimeDeparture());
                    
                    ite.setStrStatus(xPnr.getObjItinerario().get(i).getStrStatus());
                    list_iti.add(ite);
                }
                
                objSolicitud.setObjItinerario(list_iti);
                objSolicitud.setObjPasseger(list_pas);
             
                
                
            }

        } finally {
        }

        return objSolicitud;
    }
}
